<?php

function get_technorati_rank($url, $apikey)
{
	
	$technorati_xml = "http://api.technorati.com/bloginfo?key=" . $apikey . "&url=" . $url;
	$xml_parser = xml_parser_create();
	/*
	$fp = fopen($technorati_xml, "r") or die("Error: Reading XML data.");
	$data = "";
	while (!feof($fp)) {
	$data .= fread($fp, 8192);
	}
	fclose($fp);
	*/
	$data=file_get_contents_curl($technorati_xml);
	xml_parse_into_struct($xml_parser, $data, $vals, $index);
	xml_parser_free($xml_parser);
	
	$index_rank = $index['RANK'][0];
	$techno_rank = $vals[$index_rank]['value'];
	
	$index_inblogs = $index['INBOUNDBLOGS'][0];
	$techno_inblogs = number_format(trim($vals[$index_inblogs]['value']));
	$index_inlinks = $index['INBOUNDLINKS'][0];
	$techno_inlinks = number_format(trim($vals[$index_inlinks]['value']));
	$index_update = $index['LASTUPDATE'][0];
	$techno_update = trim($vals[$index_update]['value']);
	
	return $techno_rank;
}